<#import "_master.ftl" as layout />

<@layout.masterTemplate
title="Interventi">


<section id="model">
	<div class="page-header">
		<h1>
			Interventi
			<button class="btn" type="button" style="float:right;margin-left:10px" id="search">
				<i class="icon-search"></i>
				Cerca
			</button>
			<button class="btn" type="button" style="float:right" id="create-new">
				<i class="icon-plus"></i>
				Crea nuovo intervento
			</button>
		</h1>
	</div>

	<@layout.alert type="success" title="Bene!" message="Il nuovo intervento è stato creato con successo." />  	
	<@layout.alert type="error" title="Oooopppps!" message="Qualcosa è andato storto." />
	<@layout.alert type="success" title="Bene!" message="L'intervento è stato rimosso con successo." id="alert-remove-success"/>
	
	<form class="bs-docs form-horizontal" style="display:none" id="form-new" method="post">
		<button type="button" class="close" title="chiudi">×</button>
		<legend>Crea nuovo intervento</legend>
		<div class="control-group">
			<label class="control-label" for="data">Data</label>
			<div class="controls">
				<input type="text" id="data" name="data" placeholder="${.now?date?string("dd/MM/yyyy")}" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="descrizione">Descrizione</label>
			<div class="controls">
				<textarea rows="2" id="descrizione" maxLength="60" name="descrizione" placeholder="Descrizione" class="span4"></textarea>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="ascensore">Ascensore</label>
			<div class="controls">
				<select type="text" class="span6" id="ascensore" name="ascensore" placeholder="Ascensore">
					<#list ascensori as ascensore>
						<option value="${ascensore.id?string.computer}">${ascensore.modello} - ${ascensore.edificio}</option>
					</#list>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="tecnico">Tecnico</label>
			<div class="controls">
				<select type="text" class="span3" id="tecnico" name="tecnico" placeholder="Tecnico">
					<#list tecnici as tecnico>
						<option value="${tecnico.id?string.computer}">${tecnico}</option>
					</#list>
				</select>
			</div>
		</div>
		<div class="control-group">
			<div class="controls">
				<button type="submit" class="btn btn-primary" id="submit-new">Crea</button>
			</div>
		</div>
	</form>
	
	<form class="bs-docs form-horizontal" action="/InterventiPerTecnicoPerMese" style="display:none" id="form-search" method="post">
		<button type="button" class="close" title="chiudi">×</button>
		<legend>Cerca intervento</legend>
		<div class="control-group">
			<label class="control-label" for="ascensore">Tecnico</label>
			<div class="controls">
				<select type="text" class="span3" id="tecnico" name="tecnico">
					<#list tecnici as tecnico>
						<option value="${tecnico.id?string.computer}">${tecnico}</option>
					</#list>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="tecnico">Mese</label>
			<div class="controls">
				<select type="text" class="span2" id="mese" name="mese">
					<#assign mesi=["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"] />
					<#list mesi as mese>
						<option value="${mese_index}">${mese}</option>
					</#list>
				</select>
			</div>
		</div>
		<div class="control-group">
			<div class="controls">
				<button type="submit" class="btn btn-primary" id="submit-search">Cerca</button>
			</div>
		</div>
	</form>
	
	<table class="table table-striped" id="list">
		<#if ricerca ??><caption>${ricerca}</caption></#if>
		<#if (interventi?size > 0)>
		<thead>
			<tr>
				<th>#</th>
				<th>Data</th>
				<th>Descrizione</th>
				<th>Ascensore</th>
				<th>Tecnico</th>
				<th>Azioni</th>
			</tr>
		</thead>
		<tbody>

			<#list interventi as intervento>
			<tr>
				<td>${intervento.id?string.computer}</td>
				<td>${intervento.data?date?string.long}</td>
				<td>${intervento.descrizione}</td>
				<td>${intervento.ascensore.modello}</td>
				<td>${intervento.tecnico}</td>
				<td><a href="/Intervento?id=${intervento.id?string.computer}" class="icon-eye-open" title="vedi dettagli" style="cursor:pointer"></a> <a href="/removeIntervento?intervento=${intervento.id?string.computer}" class="icon-trash" title="rimuovi" style="cursor:pointer"> </a></td>
			</tr>
			</#list>
		</tbody>
		<#else>
		<tbody>
			<tr>
				<td colspan="6">Nessun intervento trovato</td>
			</tr>
		</tbody>
		</#if>
	</table>
</section>



</@layout.masterTemplate>